package yelmor.comm100.repository;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import yelmor.comm100.domain.OfMessageArchive;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by yel on 2016/5/5.
 */
public interface OfMessageArchiveRepository extends CrudRepository<OfMessageArchive, Long> {

  @Query(value = "SELECT * FROM ofMessageArchive WHERE fromJID='jack-b-service-zkbtmg3p@zy48' OR toJID='jack-b-service-zkbtmg3p@zy48'", nativeQuery = true)
  public List<OfMessageArchive> findWithJid();

/*  @Query("select u from User u where u.fromJID like %?1 or u.toJID like %?1")
  List<OfMessageArchive> findTest2(String jid);*/

  @Query(value = "SELECT * FROM ofMessageArchive WHERE fromJID = ?1 OR toJID = ?1", nativeQuery = true)
  public List<OfMessageArchive> findWithJid2(String jid);

  public OfMessageArchive findByMessageID(Long messageID);

  public List<OfMessageArchive> findByFromJIDOrToJID(String fromJid, String toJid);

  public List<OfMessageArchive> findByFromJID(String fromJid);

}
